﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace DynaSpace.Entity
{
	/// <summary>
	/// Třída sloužící pro pohon entit
	/// </summary>
	public class ParticleEngine : IEntityEngine
	{
		private Vector2 speed = Vector2.Zero;
		private float weight = 1.0f;
		
		#region IEntityEngine Members

		/// <summary>
		/// Provede update stavu entity
		/// </summary>
		/// <param name="entity">Entita, která engine používá</param>
		/// <param name="gameTime">Čas hry</param>
		public virtual void Update(EntityBase entity, GameTime gameTime)
		{
			speed += entity.Parent.gravity * Weight * (float)gameTime.ElapsedGameTime.TotalSeconds / 10f;
			UpdatePosition(gameTime, entity, ref speed); // updatovat pozici
		}

		#endregion

		/// <summary>
		/// Updatuje pozici entity
		/// </summary>
		/// <param name="gameTime">Čas hry</param>
		/// <param name="entity">Entita k updatování</param>
		/// <param name="speed">Rychlost</param>
		protected virtual void UpdatePosition(GameTime gameTime, EntityBase entity, ref Vector2 speed)
		{
			entity.Position += speed;
		}

		/// <summary>
		/// Vrací nebo nastavuje aktuální rychlost entity
		/// </summary>
		public Vector2 Speed
		{
			get
			{
				return speed;
			}
			set
			{
				speed = value;
			}
		}

		/// <summary>
		/// Vrací nebo nastavuje váhu objektu
		/// </summary>
		public float Weight
		{
			get
			{
				return weight;
			}
			set
			{
				weight = value;
			}
		}

	}
}
